import 'package:aichat_flutter_wallet/module_common/widgets/text_high_light.dart';

import 'package:flutter/cupertino.dart';

import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

import '../../../module_common/widgets/image/public_image.dart';

class DAppHistoryLoveList extends StatelessWidget {
  final String name;

  final String description;

  final String image;

  final bool isLove;

  String searchContent;

  final void Function() onClick;

  final void Function() onLove;

  DAppHistoryLoveList({
    required this.name,
    this.isLove = false,
    this.description = '',
    this.searchContent = '',
    this.image = '',
    void Function()? onClick,
    void Function()? onLove,
  })  : onClick = onClick ?? (() {}),
        onLove = onLove ?? (() {});

  @override
  Widget build(BuildContext context) {
    // TODO: implement build

    return InkWell(
      onTap: () {
        onClick();
      },
      child: Container(
        height: 70.w,
        width: double.infinity,
        padding: EdgeInsets.only(left: 20.w, right: 20.w, top: 12.w, bottom: 12.w),
        child: Row(
          mainAxisAlignment: MainAxisAlignment.center,
          crossAxisAlignment: CrossAxisAlignment.center,
          children: [
            ClipRRect(
              borderRadius: BorderRadius.circular(50.w),
              child: PublicImage(image: image, width: 46.w, height: 46.w),
            ),
            SizedBox(
              width: 10.w,
            ),
            Expanded(
                flex: 1,
                child: Column(
                  mainAxisAlignment: MainAxisAlignment.center,
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    if (name.length > 0)
                      Row(
                        children: <Widget>[
                          Expanded(
                              child: TextHighlight(
                                  name,
                                  [searchContent],
                                  TextStyle(
                                      fontSize: 14.sp,
                                      fontWeight: FontWeight.w500,
                                      color: Color.fromRGBO(51, 51, 51, 1)),
                                  TextStyle(
                                      fontSize: 14.sp,
                                      fontWeight: FontWeight.w500,
                                      color: Color.fromRGBO(134, 103, 254, 1)))),

                          // Text(

                          //   name,

                          //   style: TextStyle(

                          //       fontSize: 14,

                          //       fontWeight: FontWeight.w500,

                          //       color: Color.fromRGBO(51, 51, 51, 1)),

                          // ),
                        ],
                      ),
                    if (description.length > 0)
                      SizedBox(
                        height: 3.w,
                      ),
                    if (description.length > 0)
                      TextHighlight(
                          description,
                          [searchContent],
                          TextStyle(
                              fontSize: 12.sp, fontWeight: FontWeight.w400, color: Color.fromRGBO(190, 189, 202, 1)),
                          TextStyle(
                              fontSize: 12.sp, fontWeight: FontWeight.w400, color: Color.fromRGBO(134, 103, 254, 1))),
                  ],
                )),
            GestureDetector(
              onTap: () {
                onLove();
              },
              child: Container(
                color: Colors.transparent,
                margin: EdgeInsets.only(left: 60.w),
                height: double.infinity,
                padding: EdgeInsets.only(left: 20.w),
                alignment: Alignment.centerRight,
                child: Image.asset(
                  isLove ? 'assets/images/dapp/star-active.png' : 'assets/images/dapp/history_love.png',
                  width: 16.w,
                  height: 16.w,
                ),
              ),
            )
          ],
        ),
      ),
    );
  }
}
